#include"sort.h"

void bubbleSort(int* a,int n)
{
	assert(a);
	int tmp = 0, flag = 0;
	for (int j = 0; j < n - 1; j++)
	{
		flag = 0;
		for (int i = 0; i < n - 1 - j; i++)
			if (a[i] > a[i + 1])
			{
				tmp = a[i];
				a[i] = a[i + 1];
				a[i + 1] = tmp;
				flag = 1;
			}
		if (flag == 0) return ;
	}
}

void selectionSort(int* a,int n)
{
	assert(a);
	int i = 0,tmp = 0,flag = 0;
	for (i = 0; i < n - 1; i++)
	{
		flag = 0;
		for (int j = i + 1; j < n; j++)
			if (a[i] > a[j])
			{
				tmp = a[j];
				a[j] = a[i];
				a[i] = tmp;
				flag = 1;
			}
		if (flag == 0) return;
	}
}

void printArr(int* a, int n)
{
	assert(a);
	for (int i = 0;i<n;i++)
		printf("%d ",a[i]);
	printf("\n");
}